package com.example.amqp.service;

import com.example.amqp.constant.MqConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/2/11 10:54
 */
@Service
public class MyQueueTwoConsumer
{
    private final Logger log = LoggerFactory.getLogger(this.getClass());

    @RabbitListener(queues= MqConstant.MY_QUEUE_TWO)
    @RabbitHandler
    public void process(String content) {
        log.info("content:{}", content);
        log.info("延迟时间到，queueTwo开始执行 {}",
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
